#include <iostream>
#include <fstream>
#include <vector>

void
count_letters(const std::string& filename, std::vector<std::size_t>& count)
{
  std::ifstream input_file;
  input_file.open(filename.c_str());
  if (input_file.fail())
    {
      exit (1);
    }

  while (!input_file.eof())
    {
      char c = input_file.get();
      c = tolower(c);

      int index = c - 'a';
      if (0 <= index && index <= 25)
	{
	  count[index]++;
	}
    }

  input_file.close();
}


void
display_count(const std::vector<std::size_t>& count)
{
  for (char c = 'a'; c <= 'z'; ++c)
    {
      std::cout << c << ": " << count[c - 'a'] << std::endl;
    }
}


int main()
{
  std::string filename = "problem3.inp";

  std::ifstream input_file;
  input_file.open(filename.c_str());
  if (input_file.fail())
    {
      exit (1);
    }

  std::vector<std::size_t> count(26);
  count_letters(filename, count);
  display_count(count);
}
